import{r as s,j as e,B as v,C,c as w,R as E}from"./animations-CgUupe92.js";import"./index-Bgc6sqSm.js";const k={inhale:{duration:4,next:"hold"},hold:{duration:7,next:"exhale"},exhale:{duration:8,next:"inhale"}};function F(){const[B]=s.useState(300),[o,g]=s.useState(300),[d,h]=s.useState(!1),[I,u]=s.useState(!1),[R,x]=s.useState(0),[r,a]=s.useState("ready"),[i,N]=s.useState(null),n=s.useRef(null);s.useEffect(()=>()=>{n.current&&clearInterval(n.current),i&&clearTimeout(i)},[i]);const y=()=>{n.current&&clearInterval(n.current),n.current=setInterval(()=>{g(t=>t<=1?(m(),j(),a("complete"),alert("Breathing exercise complete! Great job!"),S(),0):t-1)},1e3)},m=()=>{n.current&&(clearInterval(n.current),n.current=null)},p=()=>{if(!d||o<=0)return;const t=k[r];if(!t)return;const l=setTimeout(()=>{r==="exhale"&&x(f=>f+1),a(t.next),p()},t.duration*1e3);N(l)},j=()=>{i&&(clearTimeout(i),N(null))},T=()=>{I?(u(!1),y(),p()):(h(!0),a("inhale"),x(0),y(),p())},P=()=>{u(!0),h(!1),m(),j(),a("paused")},S=()=>{h(!1),u(!1),g(B),x(0),a("ready"),m(),j()},$=t=>({ready:"Ready",inhale:"Breathe In",hold:"Hold",exhale:"Breathe Out",paused:"Paused",complete:"Complete!"})[t]||"Ready",b=t=>{const l=Math.floor(t/60),f=t%60;return`${l.toString().padStart(2,"0")}:${f.toString().padStart(2,"0")}`},c=()=>r==="ready"?1:r==="inhale"?2:r==="hold"?3:4;return e.jsxs("div",{className:"breathing-app",children:[e.jsxs("div",{className:"breathing-header",children:[e.jsx("h1",{children:"🌬️ Breathing Exercise"}),e.jsx("button",{className:"close-btn",onClick:()=>window.close(),title:"Close",children:"×"})]}),e.jsxs("div",{className:"breathing-content",children:[e.jsxs("div",{className:"timer-section",children:[e.jsx("div",{className:"timer-display",children:b(o)}),e.jsxs("div",{className:"timer-controls",children:[!d&&e.jsx(v,{onClick:T,variant:"primary",children:"Start"}),d&&e.jsx(v,{onClick:P,children:"Pause"}),e.jsx(v,{onClick:S,children:"Reset"})]})]}),e.jsx("div",{className:"breathing-circle-container",children:e.jsx("div",{className:`breathing-circle ${r}`,children:e.jsx("div",{className:"circle-inner",children:e.jsx("span",{children:$(r)})})})}),e.jsxs("div",{className:"instructions-section",children:[e.jsx("h2",{children:"Instructions"}),e.jsxs("div",{className:"instructions-content",children:[e.jsxs("div",{className:`instruction-step ${c()===1?"active":""}`,children:[e.jsx("h3",{children:"1. Find a comfortable position"}),e.jsx("p",{children:"Sit or lie down in a comfortable position. Close your eyes if you prefer."})]}),e.jsxs("div",{className:`instruction-step ${c()===2?"active":""}`,children:[e.jsx("h3",{children:"2. Follow the breathing pattern"}),e.jsx("p",{children:"Breathe in when the circle expands, breathe out when it contracts."})]}),e.jsxs("div",{className:`instruction-step ${c()===3?"active":""}`,children:[e.jsx("h3",{children:"3. 4-7-8 Technique"}),e.jsx("p",{children:"Inhale for 4 seconds, hold for 7 seconds, exhale for 8 seconds."})]}),e.jsxs("div",{className:`instruction-step ${c()===4?"active":""}`,children:[e.jsx("h3",{children:"4. Stay relaxed"}),e.jsx("p",{children:"Focus on your breath and let go of any tension. Repeat for 5 minutes."})]})]})]}),e.jsxs("div",{className:"breathing-stats",children:[e.jsxs(C,{className:"stat-item",children:[e.jsx("span",{className:"stat-label",children:"Cycles"}),e.jsx("span",{className:"stat-value",children:R})]}),e.jsxs(C,{className:"stat-item",children:[e.jsx("span",{className:"stat-label",children:"Time Remaining"}),e.jsx("span",{className:"stat-value",children:b(o)})]})]})]})]})}const A=w.createRoot(document.getElementById("root"));A.render(e.jsx(E.StrictMode,{children:e.jsx(F,{})}));
